package com.psytech.app.task.web_ui.driver;

import java.util.List;

import javax.security.auth.login.CredentialException;

import com.psytech.app.task.web_ui.Group;
import com.psytech.app.task.web_ui.User;
import com.psytech.app.task.web_ui.driver.exception.ObjectNotFoundException;

/**
 * This interface describes all the methods that must implement the driver.
 * </br> The "UserDriver" is the adapter between Taskman and the user
 * repository. </br>
 * 
 * @author ben
 * 
 */
public interface UserDriverInterface extends AuthInterface {

	/**
	 * Get the list of groups associated with the user.</br>
	 * 
	 * @param userUid
	 *            the user uid for whom you search groups.
	 * @return the list of groups. If the user is not in any group, an empty
	 *         list is returned.
	 * @throws ObjectNotFoundException
	 *             when there is no matching user
	 */
	List<Group> getUserGroups(String userUid) throws ObjectNotFoundException;

	/**
	 * Get the member list associated with the group.</br>
	 * 
	 * @param groupUid
	 *            the group uid for whom you search users.
	 * @return the list of users. If the group contains no user, an empty list
	 *         is returned.
	 * @throws ObjectNotFoundException
	 *             when there is no matching group
	 */
	List<User> getGroupMembers(String groupUid) throws ObjectNotFoundException;

	/**
	 * Get the User associated to the given id.
	 * 
	 * @param uid
	 *            unique id of a user
	 * @return the user linked to the uid
	 * @throws ObjectNotFoundException
	 *             when there is no matching user
	 */
	User getUserByUid(String uid) throws ObjectNotFoundException;

	/**
	 * Authenticate the user by his login and password
	 * 
	 * @param login
	 * @param password
	 * @return the authenticate user
	 * @throws CredentialException
	 */
	User getUserByCredential(String login, String password) throws CredentialException;

	/**
	 * Authenticate the user by a token
	 * 
	 * @param token
	 * @return the authenticate user
	 * @throws CredentialException
	 */
	User getUserByAuthenticationToken(String token) throws CredentialException;
}
